<template>
  <el-container class="container">
    <el-header height="80px">
      <el-row id="title">
        <el-image src="./images/name.png"></el-image>
      </el-row>
      <el-row class="detail">
        <!-- <div >Easy出行 轻松出行 你身边的出行管家</div> -->
        <el-image src="./images/detailText.png"/>
      </el-row>
      <el-row index="5" class="my-center" style="flex:2;">
        <div>
          <span style="margin-right:10px">{{admUsername}}</span>
          <el-button type="info" id="exit" plain @click="exit()">退出</el-button>
        </div>
      </el-row>
    </el-header>
    <el-container>
      <el-aside>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="black"
          text-color="#fff"
          active-text-color="yellow"
        >
          <router-link to="/AdmSystem/LessorList" tag="div">
            <el-menu-item index="2">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">出租方</span>
            </el-menu-item>
          </router-link>
          <router-link to="/AdmSystem/RentalList" tag="div">
            <el-menu-item index="3">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">承租方</span>
            </el-menu-item>
          </router-link>
          <router-link to="/AdmSystem/AdminList" tag="div">
            <el-menu-item index="4">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">管理员</span>
            </el-menu-item>
          </router-link>
          <router-link to="/AdmSystem/CarList" tag="div">
            <el-menu-item index="1">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">车辆管理</span>
            </el-menu-item>
          </router-link>
          <router-link to="/AdmSystem/MyCenter" tag="div">
            <el-menu-item index="5">
              <!-- <i class="el-icon-menu"></i> -->
              <span slot="title">个人中心</span>
            </el-menu-item>
          </router-link>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
    <el-footer>Footer</el-footer>
  </el-container>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      activeIndex: "1",
      toggle: { active1: true, active2: false, active3: false, active4: false },
      admUsername: ""
    };
  },
  created() {
    this.isLogin();
  },
  methods: {
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
    },
    async isLogin() {
      const { data } = await axios.get("/adm/isLogin");
      console.log(data);
      if (data.success == false && data.status == "401") {
        console.log("登录过期,请重新登录!");
        alert("用户信息过期 请重新登录！");
        this.$router.push("/login");
      } else if (data.success == true && data._id) {
        console.log(data._id);
        const user = await axios.get("/adm/getAdm", {
          params: { _id: data._id }
        });
        console.log("当前登录用户", user.data);
        this.admUsername = user.data.username;
      }
    },
    // 退出登录
    exit() {
      this.$router.push("/login");
    }
  },
  components: {}
};
</script>


<style>
.container {
  background-color: black;
  height: 100vh !important;
}
.el-header{
  height: 8vh;
  padding: 0;
}
#title {
  flex: 2;
  padding-left: 50px !important;
  display: flex;
  align-items: center;
}
.detail{
  flex:5;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}
.detail .el-image{
  width: 300px;
  height: 40px;
}
.el-aside {
  height: 80vh !important;
  width: 200px !important;
  background-color: black !important;
}
.el-menu-item {
  padding: 0 !important;
  height: 100% !important;
  text-align: center;
}
#title .el-image {
  width: 120px;
}
#head-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.my-center {
  flex: 2;
  display: flex;
  justify-content: center;
}
.my-center > div {
  cursor: pointer;
  display: flex;
  padding: 0 30px !important;
  justify-content: center;
  align-items: center;
}
.my-center #exit:hover {
  color: yellow;
}
.my-center #exit {
  height: 40px;
}
.el-image {
  display: flex;
  align-items: center;
  margin-right: 10px;
}
.tab {
  text-align: center;
}
.tab#active {
  color: yellow !important;
}
.tab:hover {
  color: yellow !important;
}
.el-header {
  font-size: 16px;
  height: 65px !important;
  line-height: 65px;
  display: flex;
  background-color: black;
}
.el-header .el-row {
  color: white;
}

.container {
  height: auto;
}
.el-footer {
  background-color: black;
  color: #333;
  text-align: center;
  height: 5vh !important;
  line-height: 38px !important;
}
.el-main {
  background-color: #fff;
  overflow: hidden;
  color: #333;
  text-align: center;
  height: 80vh;
}
</style>